﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AcmeSportsStore
{
    public partial class SportsView : Form
    {
        private LayoutController mLayoutController = null;
        private PasswordView passwordForm;            
        private NewPasswordView newPasswordForm;

        public SportsView()
        {
            InitializeComponent();
        }
        /*
      * <<<<<<<---
      * set properties of the following tools for 'Enable' function
      */
        public TabControl MainTabControl
        {
            get
            { return tabctlMain; }
        }

        public ToolStripMenuItem MainMenuFile
        {
            get { return MenuFile; }
        }

        public ToolStripMenuItem MainMenuEdit
        {
            get { return MenuEdit; }
        }

        public ToolStripMenuItem MainMenuHelp
        {
            get { return MenuHelp; }
        }

        public ToolStripMenuItem MainMenuLogin
        {
            get { return Login_MenuLog; }
        }

        public ToolStripMenuItem MainMenuLogoff
        {
            get { return Logoff_MenuLog; }
        }

        public ToolStripStatusLabel StatusLbl1
        {
            get { return statusLabel1; }
        }

        public ToolStripStatusLabel StatusLbl2
        {
            get { return statusLabel2; }
        }
        /*
         * ---- >>>>>>>>>>>
         */
        private void SportsView_Load(object sender, EventArgs e)
        {
            mLayoutController = new LayoutController(this.tabctlMain);
            passwordForm = new PasswordView();
            newPasswordForm = new NewPasswordView();
            this.imgSportsItems.ImageSize = this.pbxPreview.Size;
             
            // load images from the resource

            this.imgSportsItems.Images.Add("basketball",
                AcmeSportsStore.Properties.Resources.M0001_basketball);
            this.imgSportsItems.Images.Add("netball",
                AcmeSportsStore.Properties.Resources.M0002_netball);
            this.imgSportsItems.Images.Add("soccer",
                AcmeSportsStore.Properties.Resources.M0003_soccer);
            this.imgSportsItems.Images.Add("boxingGloves",
                AcmeSportsStore.Properties.Resources.M0004_boxingGloves);
            this.imgSportsItems.Images.Add("boxMitts",
                AcmeSportsStore.Properties.Resources.M0005_boxMitts);
            this.imgSportsItems.Images.Add("helmet",
                AcmeSportsStore.Properties.Resources.M0006_helmet);
            this.imgSportsItems.Images.Add("chess",
                AcmeSportsStore.Properties.Resources.M0007_chess);


            foreach (string s in imgSportsItems.Images.Keys)
            {
                cmbItemID.Items.Add(s);
            }
        }

        private void btnSportItem_Click(object sender, EventArgs e)
        {
            /*
             * select the 2nd tab
             */
            tabctlMain.SelectedIndex = 1;
        }

        private void btnCustomer_Click(object sender, EventArgs e)
        {
            /*
             * select the 3rd tab
             */
            tabctlMain.SelectedIndex = 2;
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cmbItemID_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selText = (string)this.cmbItemID.SelectedItem;
            Image image = this.imgSportsItems.Images[selText];
            pbxPreview.Image = image;
            pbxPreview.Invalidate();
        }

        private void btnHomeFromTab2_Click(object sender, EventArgs e)
        {
            /*
             *  go back to the home page
             */
            this.tabctlMain.SelectedIndex = 0;
        }

        private void btnHomeFromTab3_Click(object sender, EventArgs e)
        {
            /*
             *  go back to the home page
             */
            this.tabctlMain.SelectedIndex = 0;
        }

        private void Admin_MenuLogin_Click(object sender, EventArgs e)
        {
            passwordForm.ShowDialog(this);
        }

        private void SportsView_Resize(object sender, EventArgs e)
        {
            if (mLayoutController != null)
            {
                mLayoutController.UpdateAfterResizing();
            }
        }

        private void Logoff_MenuLog_Click(object sender, EventArgs e)
        {
            MenuFile.Enabled = false;
            MenuEdit.Enabled = false;
            MenuHelp.Enabled = false;
            tabctlMain.Enabled = false;
            Login_MenuLog.Enabled = true;
            Logoff_MenuLog.Enabled = false;
            statusLabel1.Text = " ";
        }

        private void Exit_MenuLog_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ChPassWord_MenuEdit_Click(object sender, EventArgs e)
        {
            newPasswordForm.ShowDialog(this);
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            OpenFileDg.ShowDialog();
        }

        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            saveFileDg.ShowDialog();
        }

    }
}
